﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Googler.DAL;

namespace Googler.Web
{
    public partial class FaildToExtract : System.Web.UI.Page
    {
        class FaildToExtractLink
        {
            public string Url { get; set; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            BindFaildUrls();
        }
        void BindFaildUrls()
        {
            List<FaildToExtractLink> list = new List<FaildToExtractLink>();

            var context = new DataContext();

            var urlList = context.TestedUrls.ToList();
            if (urlList != null)
            {
                urlList.ForEach(u =>
                    list.Add(new FaildToExtractLink()
                    {
                        Url = u.Url
                    })
                );
            }

            var newsList = context.News.Where(n => n.IsExtracted != null && n.IsExtracted.Value == false).ToList();
            if (newsList != null)
            {
                newsList.ForEach(n => list.Add(new FaildToExtractLink()
                {
                    Url = n.Link
                }));
            }

            rptUrls.DataSource = list;
            rptUrls.DataBind();
        }
    }
}